And make the struct public, so we can use it in signal handlers.
GtkCssParserError
GtkCssParserWarning
<SUBSECTION>
+GtkCssLocation
GtkCssSection
GtkCssSectionType
gtk_css_section_get_end_line
#include <gtk/css/gtkcssenums.h>
#include <gtk/css/gtkcssenumtypes.h>
#include <gtk/css/gtkcsserror.h>
+#include <gtk/css/gtkcsslocation.h>
#undef __GTK_CSS_H_INSIDE__
--- /dev/null
+/* GSK - The GIMP Toolkit
+ * Copyright (C) 2019 Benjamin Otte <otte@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkcsslocationprivate.h"
+
+/**
+ * GtkCssLocation:
+ * @bytes: number of bytes parsed since the beginning
+ * @chars: number of characters parsed since the beginning
+ * @lines: number of full lines that have been parsed
+ * If you want to display this as a line number, you
+ * need to add 1 to this.
+ * @line_bytes: Number of bytes parsed since the last line break
+ * @line_chars: Number of characters parsed since the last line
+ * break
+ *
+ * @GtkCssLocation is used to present a location in a file - or other
+ * source of data parsed by the CSS engine.
+ *
+ * The @bytes and @line_bytes offsets are meant to be used to
+ * programmatically match data. The @lines and @line_chars offsets
+ * can be used for printing the location in a file.
+ *
+ * Note that the @lines parameter starts from 0 and is increased
+ * whenever a CSS line break is encountered. (CSS defines the C character
+ * sequences "\r\n", "\r", "\n" and "\f" as newlines.)
+ * If your document uses different rules for line breaking, you might want
+ * run into problems here.
+ */
+
+void
+gtk_css_location_init (GtkCssLocation *location)
+{
+ memset (location, 0, sizeof (GtkCssLocation));
+}
+
+void
+gtk_css_location_advance (GtkCssLocation *location,
+ gsize bytes,
+ gsize chars)
+{
+ location->bytes += bytes;
+ location->chars += chars;
+ location->line_bytes += bytes;
+ location->line_chars += chars;
+}
+
+void
+gtk_css_location_advance_newline (GtkCssLocation *location,
+ gboolean is_windows)
+{
+ gtk_css_location_advance (location, is_windows ? 2 : 1, is_windows ? 2 : 1);
+
+ location->lines++;
+ location->line_bytes = 0;
+ location->line_chars = 0;
+}
+
--- /dev/null
+/* GSK - The GIMP Toolkit
+ * Copyright (C) 2011 Benjamin Otte <otte@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_CSS_LOCATION_H__
+#define __GTK_CSS_LOCATION_H__
+
+#if !defined (__GTK_CSS_H_INSIDE__) && !defined (GTK_CSS_COMPILATION)
+#error "Only <gtk/css/gtkcss.h> can be included directly."
+#endif
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GtkCssLocation GtkCssLocation;
+
+struct _GtkCssLocation
+{
+ gsize bytes;
+ gsize chars;
+ gsize lines;
+ gsize line_bytes;
+ gsize line_chars;
+};
+
+
+G_END_DECLS
+
+#endif /* __GTK_CSS_LOCATION_H__ */
--- /dev/null
+/*
+ * Copyright © 2019 Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+
+#ifndef __GTK_CSS_LOCATION_PRIVATE_H__
+#define __GTK_CSS_LOCATION_PRIVATE_H__
+
+#include "gtkcsslocation.h"
+
+G_BEGIN_DECLS
+
+void gtk_css_location_init (GtkCssLocation *location);
+
+void gtk_css_location_advance (GtkCssLocation *location,
+ gsize bytes,
+ gsize chars);
+void gtk_css_location_advance_newline (GtkCssLocation *location,
+ gboolean is_windows);
+
+G_END_DECLS
+
+#endif /* __GTK_CSS_LOCATION_PRIVATE_H__ */
+
#include "gtkcsstokenizerprivate.h"
-/* for error enum */
#include "gtkcssenums.h"
#include "gtkcsserror.h"
+#include "gtkcsslocationprivate.h"
#include <math.h>
#include <string.h>
GtkCssLocation position;
};
-static void
-gtk_css_location_init (GtkCssLocation *location)
-{
- memset (location, 0, sizeof (GtkCssLocation));
-}
-
-static void
-gtk_css_location_advance (GtkCssLocation *location,
- gsize bytes,
- gsize chars)
-{
- location->bytes += bytes;
- location->chars += chars;
- location->line_bytes += bytes;
- location->line_chars += chars;
-}
-
-static void
-gtk_css_location_advance_newline (GtkCssLocation *location,
- gboolean is_windows)
-{
- gtk_css_location_advance (location, is_windows ? 2 : 1, is_windows ? 2 : 1);
-
- location->lines++;
- location->line_bytes = 0;
- location->line_chars = 0;
-}
-
void
gtk_css_token_clear (GtkCssToken *token)
{
#include <glib.h>
+#include <gtk/css/gtkcsslocation.h>
+
G_BEGIN_DECLS
typedef enum {
typedef union _GtkCssToken GtkCssToken;
typedef struct _GtkCssTokenizer GtkCssTokenizer;
-typedef struct _GtkCssLocation GtkCssLocation;
typedef struct _GtkCssStringToken GtkCssStringToken;
typedef struct _GtkCssDelimToken GtkCssDelimToken;
GtkCssDimensionToken dimension;
};
-struct _GtkCssLocation
-{
- gsize bytes;
- gsize chars;
- gsize lines;
- gsize line_bytes;
- gsize line_chars;
-};
-
void gtk_css_token_clear (GtkCssToken *token);
gboolean gtk_css_token_is_finite (const GtkCssToken *token);
gtk_css_public_sources = files([
+ 'gtkcsslocation.c',
'gtkcsserror.c',
])
gtk_css_public_headers = files([
'gtkcssenums.h',
'gtkcsserror.h',
+ 'gtkcsslocation.h',
])
install_headers(gtk_css_public_headers, 'gtkcss.h', subdir: 'gtk-4.0/gtk/css')